/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MTI
 */
@Entity
@Table(name = "COUNTY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "County.findAll", query = "SELECT c FROM County c"),
    @NamedQuery(name = "County.findById", query = "SELECT c FROM County c WHERE c.id = :id"),
    @NamedQuery(name = "County.findByCountyname", query = "SELECT c FROM County c WHERE c.countyname = :countyname"),
    @NamedQuery(name = "County.findByPassive", query = "SELECT c FROM County c WHERE c.passive = :passive"),
    @NamedQuery(name = "County.findAllByCityId", query = "SELECT c FROM County c WHERE c.cityid = :cityid")})
public class County implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "COUNTYNAME")
    private String countyname;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PASSIVE")
    private int passive;
    @OneToMany(mappedBy = "countyid")
    private Collection<Customer> customerCollection;
    @JoinColumn(name = "CITYID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Citys cityid;

    public County() {
    }

    public County(Integer id) {
        this.id = id;
    }

    public County(Integer id, String countyname, int passive) {
        this.id = id;
        this.countyname = countyname;
        this.passive = passive;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCountyname() {
        return countyname;
    }

    public void setCountyname(String countyname) {
        this.countyname = countyname;
    }

    public int getPassive() {
        return passive;
    }

    public void setPassive(int passive) {
        this.passive = passive;
    }

    @XmlTransient
    public Collection<Customer> getCustomerCollection() {
        return customerCollection;
    }

    public void setCustomerCollection(Collection<Customer> customerCollection) {
        this.customerCollection = customerCollection;
    }

    public Citys getCityid() {
        return cityid;
    }

    public void setCityid(Citys cityid) {
        this.cityid = cityid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof County)) {
            return false;
        }
        County other = (County) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.County[ id=" + id + " ]";
    }
    
}
